<!doctype html>
<html lang="en" class="fullscreen-bg">

<head>
	<title><%= title %></title>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<!-- VENDOR CSS -->
	<link rel="stylesheet" href="/BackStage/assets/css/bootstrap.min.css">
	<link rel="stylesheet" href="/BackStage/assets/vendor/font-awesome/css/font-awesome.min.css">
	<link rel="stylesheet" href="/BackStage/assets/vendor/linearicons/style.css">
	<!-- MAIN CSS -->
	<link rel="stylesheet" href="/BackStage/assets/css/main.css">
	<!-- FOR DEMO PURPOSES ONLY. You should remove this in your project -->
	<link rel="stylesheet" href="/BackStage/assets/css/demo.css">
	<!-- GOOGLE FONTS -->
	<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700" rel="stylesheet">
	<!-- ICONS -->
	<link rel="apple-touch-icon" sizes="76x76" href="/BackStage/assets/img/apple-icon.png">
	<link rel="icon" type="image/png" sizes="96x96" href="/BackStage/assets/img/favicon.png">
	<script src="/BackStage/js/jquery-1.8.3.js"></script>
	
</head>

<body>
	<!-- WRAPPER -->
	<div id="wrapper">
		<div class="vertical-align-wrap">
			<div class="vertical-align-middle">
				<div class="auth-box ">
					<div class="left">
						<div class="content">
							<div class="header">
								<div class="logo text-center"><img src="/BackStage/assets/img/logo-dark.png" alt="Klorofil Logo"></div>
								<p class="lead">登入你的系统</p>
							</div>
							
								<div class="form-group">
									<label for="signin-email" class="control-label sr-only">用户名</label>
									<input type="text" list="browsers" class="form-control" id="signin-email" value="" placeholder="staffNo">
									<datalist id="browsers" style="max-height:150px; overflow:auto;">
									</datalist>
								</div>
								<div class="form-group">
									<label for="signin-password" class="control-label sr-only">密码</label>
									<input type="password" class="form-control" id="signin-password" value="" placeholder="staffPass">
								</div>
								<div class="form-group clearfix" style="text-align:left">
									<label class="fancy-checkbox element-left">
										<input type="checkbox" checked = 'true'>
										<span>记住我</span>
									</label>
								</div>
								<button type="button" class="btn btn-primary btn-lg btn-block" onclick="login();" >登陆</button>
								<!-- <div class="bottom">
									<span class="helper-text"><i class="fa fa-lock"></i> <a href="#">忘记密码?</a></span>
								</div> -->
							
						</div>
					</div>
					<div class="right">
						<div class="overlay"></div>
						<div class="content text">
							<h1 class="heading">Free Bootstrap dashboard template</h1>
							<p>by The Develovers</p>
						</div>
					</div>
					<div class="clearfix"></div>
				</div>
			</div>
		</div>
	</div>
	<!-- END WRAPPER -->
</body>

	<script>
		
		 function findstaffName(){
            var hp = new XMLHttpRequest();
            hp.open('get', '/message/findstaffName', true);
            hp.send();
            hp.onreadystatechange = function () {
                if (hp.status == 200) {
                    if (hp.readyState == 4) {
                        var datas = eval("(" + hp.responseText + ")");
                        for(var i=0;i<datas.length;i++){
							$("#browsers").append('<option label="'+datas[i].name+'" value="'+datas[i].no+'"></option>');
							
							// sessionStorage.setItem('a','123');
                        }
                    }
                }
            }
		}
		
		$().ready(function(){
			findstaffName();
		});
		function login(){
			$.ajax({
				type: "POST",
				url: "/login/",
				data: "staffNo="+$('#signin-email').val()+"&staffPass="+$('#signin-password').val(),
				success: function(data){
					// alert(data.Result);
					if('ok' === data.Result){
						window.location.href = '/BackStage/index';
					}else{
						alert('密码错误,请重试');
						window.location.href = '/BackStage/';
					}
				}
			}); 
		}
	</script>
</html>
